package com.ardo.controller;

import com.ardo.entity.vo.Query;
import com.ardo.service.NoticeService;
import com.ardo.utils.AppUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * 消息通知
 * E***
 */
@RestController
@RequestMapping("/notice")
public class NoticeController {

    @Autowired
    private NoticeService noticeService;

    @RequestMapping("/list")
    public String list(HttpServletRequest request) {
        AppUtils.printTitle("E001 - 消息通知列表查询");
        String pageSize  = request.getParameter("pageSize");
        Query query = new Query();
        if(!StringUtils.isEmpty(pageSize)){
            query.setPageSize(Integer.parseInt(pageSize));
        }else{
            query.setPageSize(10);//默认
        }
        String result = noticeService.queryNoticeList(query);
        //System.out.println("消息通知列表查询结果: " + result);
        return result;
    }

    @RequestMapping("/detail")
    public String detail(HttpServletRequest request) {
        AppUtils.printTitle("E002 - 消息通知详情");
        String id  = request.getParameter("id");
        String result = noticeService.queryNoticeDetail(Integer.parseInt(id));
        //System.out.println("消息通知详情结果: " + result);
        return result;
    }
}
